package com.tgy;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;

/***
 * @ClassName: DeptProvider_01
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 20:05 2022/1/10
 * @version : V1.0
 */
@SpringBootApplication
@EnableEurekaClient//开启Eureka服务端
@EnableDiscoveryClient
@EnableHystrix // 添加对熔断的支持注解
public class DeptProviderHystrix {
    public static void main(String[] args) {
        SpringApplication.run(DeptProviderHystrix.class, args);
    }

    //增加一个 Servlet
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        //访问该页面就是监控页面
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        return registrationBean;
    }
}
